from common.config import *
import requests
import allure
from common.log_info import Logger

distribution = Logger("distribution", "distribution").logger


class Distribution:
    pass

    #
    @allure.testcase("金刚位-banner配置")
    def diamond_banner_config(self, env, qwc_token, data):
        base_url = getconf(env, "qwc_url")
        url = base_url + "flashmall-distribution-server/v1/ui-config/entrance-save"
        headers = {"content-type": "application/json;charset=UTF-8",
                   "token": qwc_token}
        distribution.info(f"金刚位-banner配置的请求参数：{data}")
        return requests.post(url, headers=headers, json=data)

    @allure.testcase("栏目配置")
    def column_config(self, env, qwc_token, data):
        base_url = getconf(env, "qwc_url")
        url = base_url + "flashmall-distribution-server/v1/ui-config/section-save"
        headers = {"content-type": "application/json;charset=UTF-8",
                   "token": qwc_token}
        distribution.info(f"金刚位-banner配置的请求参数：{data}")
        return requests.post(url, headers=headers, json=data)

    @allure.testcase("查询金刚位-banner配置")
    def get_diamond_banner_config(self, env, qwc_token, data):
        base_url = getconf(env, "qwc_url")
        url = base_url + "flashmall-distribution-server/v1/ui-config/entrance-info"
        headers = {"content-type": "application/json;charset=UTF-8",
                   "token": qwc_token}
        distribution.info(f"金刚位-banner配置的请求参数：{data}")
        return requests.post(url, headers=headers, json=data)

    @allure.testcase("查询栏目配置")
    def column_config(self, env, qwc_token):
        base_url = getconf(env, "qwc_url")
        url = base_url + "flashmall-distribution-server/v1/ui-config/section-info"
        headers = {"content-type": "application/json;charset=UTF-8",
                   "token": qwc_token}
        return requests.get(url, headers=headers)
